Skip to content

Add iotools functions for Meteonorm #2499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

AdamRJensen
Copy link
Member

@AdamRJensen AdamRJensen commented Jul 15, 2025

  • I am familiar with the contributing guidelines
  • Tests added
  • Updates entries in docs/sphinx/source/reference for API changes.
  • Adds description and name entries in the appropriate "what's new" file in docs/sphinx/source/whatsnew for all changes. Includes link to the GitHub Issue with :issue:`num` or this Pull Request with :pull:`num`. Includes contributor name and/or GitHub username (link with :ghuser:`user`).
  • New code is fully documented. Includes numpydoc compliant docstrings, examples, and comments where necessary.
  • Pull request is nearly complete and ready for detailed review.
  • Maintainer: Appropriate GitHub Labels (including remote-data) and Milestone are assigned to the Pull Request and linked Issue.

This PR adds functions for retrieving irradiance and weather data from Meteonorm. This is the last function I plan on contributing to the commercial iotools, as pvlib then will support what I consider the major providers of satellite-derived irradiance data.

Documentation:

For anyone willing to review this PR, I can provide a temporary API key.

@AdamRJensen AdamRJensen added this to the v0.13.1 milestone Jul 15, 2025
@AdamRJensen AdamRJensen added the io label Jul 15, 2025
Copy link
Contributor

@IoannisSifnaios IoannisSifnaios left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor things here and there. Otherwise LGTM!

AdamRJensen and others added 9 commits August 2, 2025 15:50
Co-authored-by: Ioannis Sifnaios <88548539+IoannisSifnaios@users.noreply.github.com>
Co-authored-by: Ioannis Sifnaios <88548539+IoannisSifnaios@users.noreply.github.com>
@AdamRJensen AdamRJensen added the remote-data triggers --remote-data pytests label Aug 2, 2025
@AdamRJensen AdamRJensen added remote-data triggers --remote-data pytests and removed remote-data triggers --remote-data pytests labels Aug 2, 2025
@AdamRJensen AdamRJensen added remote-data triggers --remote-data pytests and removed remote-data triggers --remote-data pytests labels Aug 2, 2025
@AdamRJensen AdamRJensen marked this pull request as ready for review August 2, 2025 20:32
@AdamRJensen AdamRJensen requested a review from kandersolar August 2, 2025 20:33
Copy link

@maschwanden maschwanden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, my name is Mathias, and I'm a developer of the Meteonorm API. First of all, thanks for creating pvlib; it's a very nice library we often use for reference. We're excited to see Meteonorm being integrated. @AdamRJensen reached out to us, and I'm here to review the merge request.

.. autosummary::
:toctree: generated/

iotools.get_meteonorm

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Solcast there are specialized functions for retrieving TMY, historical and forecast data. For Meteonorm there is currently only a TMY and a "everthing else" getter function (for the endpoints /observation/training, /observation/realtime, /forecast/basic, and /forecast/precision). What's the reasoning behind implementing get_meteonorm instead of get_meteonorm_observation_training, get_meteonorm_observation_realtime, get_meteonorm_forecast_basic, and get_meteonorm_forecast_precision? There are pros and cons for both variants, but i would argue, that for the end user it's easier if there's a specialized function for every endpoint.

Copy link
Member Author

@AdamRJensen AdamRJensen Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be convinced to have a separate function for get_meteonorm_observation and get_meteonorm_forecast with a keyword parameter to switch between the subcases. The main motivation is to reduce the duplicate docstring and reduce the maintenance burden.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the right answer here is. Maybe @AdamRJensen's proposal is the best balance.

Copy link

@maschwanden maschwanden Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I see that this is a maintenance nightmare with doc-strings of this size.
I assume messing around with the __doc__ field to share a part of the documentation is not really an option; this becomes unreadable very fast.

Despite that, every request to the API costs the user real money and thus I'm critical about using parameters - instead of separate functions - to decide which endpoint to call.

[...] keyword parameter to switch between the subcases.

@AdamRJensen How would this look like? One option would be to use the exact same signature but the value to the parameter endpoint has to be "basic"/"precision" for get_meteonorm_forecast and "realtime"/"training" for get_meteonorm_observation.
Note that there is no parameter frequency for the /forecast/basic endpoint, thus it would be a good idea to raise a warning or exception if the user uses endpoint="basic", time_step="1min".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AdamRJensen How would this look like? One option would be to use the exact same signature but the value to the parameter endpoint has to be "basic"/"precision" for get_meteonorm_forecast and "realtime"/"training" for get_meteonorm_observation. Note that there is no parameter frequency for the /forecast/basic endpoint, thus it would be a good idea to raise a warning or exception if the user uses endpoint="basic", time_step="1min".

@maschwanden If we are to split it into separate forecast and observation functions, then this is exactly how I envisioned it. I'm curious what other members of @pvlib/pvlib-maintainer have to say about this.

Also, I've added an error message if the basic forecast is requested with a frequency other than '1_hour'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maschwanden Check out the changes in the last commit. Would this approach be ok with you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, @maschwanden proposed meteonorm.get_meteonorm_observation_training is similar to the existing solcast.get_solcast_historic function and the meteonorm.get_meteonorm_observation_realtime is similar to the solcast.get_solcast_live function. I would favor API parallelism over concerns about docstrings.

@AdamRJensen AdamRJensen added remote-data triggers --remote-data pytests and removed remote-data triggers --remote-data pytests labels Aug 4, 2025
Copy link
Member

@kandersolar kandersolar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only read the code (did not try it myself).

.. autosummary::
:toctree: generated/

iotools.get_meteonorm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the right answer here is. Maybe @AdamRJensen's proposal is the best balance.

@AdamRJensen AdamRJensen added remote-data triggers --remote-data pytests and removed remote-data triggers --remote-data pytests labels Aug 4, 2025
@AdamRJensen AdamRJensen added remote-data triggers --remote-data pytests and removed remote-data triggers --remote-data pytests labels Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
io remote-data triggers --remote-data pytests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants